﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SSSGame
{
    /// <summary>
    /// Fournit des méthodes d'animation pour les balises
    /// </summary>
    public class TagAnimation
    {
        private Color _tagColorCache;
        private float _tagScale;
        private bool _isUpState;

        public float Speed { get; set; }

        public Color GetTagColor()
        {
            return _tagColorCache;
        }

        public float GetScale()
        {
            return _tagScale;
        }

        public TagAnimation(float speed)
        {
            Speed = speed;
            _isUpState = false;
            _tagColorCache = new Color(255, 255, 255);
            _tagScale = 1.5f;
        }

        public void GetAnimation(GameTime gameTime)
        {
            if (_isUpState)
            {
                _tagColorCache.R += (byte)(gameTime.ElapsedGameTime.Milliseconds * Speed);
                _tagColorCache.G += (byte)(gameTime.ElapsedGameTime.Milliseconds * Speed);
                _tagColorCache.B += (byte)(gameTime.ElapsedGameTime.Milliseconds * Speed);

                if (_tagColorCache.R >= 255)
                {
                    _tagColorCache.R = 255;
                    _tagColorCache.G = 255;
                    _tagColorCache.B = 255;
                    _isUpState = false;
                }
            }
            else
            {
                _tagColorCache.R -= (byte)(gameTime.ElapsedGameTime.Milliseconds * Speed);
                _tagColorCache.G -= (byte)(gameTime.ElapsedGameTime.Milliseconds * Speed);
                _tagColorCache.B -= (byte)(gameTime.ElapsedGameTime.Milliseconds * Speed);

                if (_tagColorCache.R <= 0)
                {
                    _tagColorCache.R = 0;
                    _tagColorCache.G = 0;
                    _tagColorCache.B = 0;
                    _isUpState = true;
                }
            }
        }
    }
}
